//
//  FavTabDetailController.m
//  FavClient
//
//  Created by MagicStudio on 12-4-17.
//  Copyright 2012年 __MyCompanyName__. All rights reserved.
//

#import "FavTabDetailController.h"
#import "FavTabController.h"
#import "FavHelper.h"


@implementation FavTabDetailController

@synthesize backItem ;
@synthesize backController ;
@synthesize navigationBar ;
@synthesize mTitle ;
@synthesize arrayImage ;
@synthesize mTableView ;


#pragma Mark-



#pragma Mark-

-(IBAction) backEvent:(id)sender{
    //NSLog(@"safasfsadfasdf ") ;
   // [self.view removeFromSuperview] ;
    FavTabController *_backController = [[FavTabController alloc] initWithNibName:@"FavTabController" bundle:nil] ;
    self.backController = _backController ;
    CATransition *anim = [UIViewAnimationHelper getCATAnimation:0.7f type:Type_SuckEffect] ;
    [ViewChangeHelper changeControllerForSelf:self.backController disAppearController:self catTrasition:anim] ;
    [_backController release] ;
    
}

#pragma Mark-
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [backItem release] ;
    [backController release] ;
    [navigationBar release] ;
    [mTitle release] ;
    [arrayImage release] ;
    [mTableView release] ;
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{   
    [self.mTableView setBackgroundColor:[UIColor clearColor]] ;
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

#pragma Mark- UITableDataSource And UITableDelegate Method

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [self.arrayImage count] ;
}

// Row display. Implementers should *always* try to reuse cells by setting each cell's reuseIdentifier and querying for available reusable cells with dequeueReusableCellWithIdentifier:
// Cell gets various attributes set automatically based on table (separators) and data source (accessory views, editing controls)

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *FAVTABDETAILCELL = @"FAVTABDETAILCELL" ;
    FavTabDetailCell *cell = (FavTabDetailCell *)[tableView dequeueReusableCellWithIdentifier:FAVTABDETAILCELL] ;
    if(cell == nil){
        cell = [[[NSBundle mainBundle] loadNibNamed:@"FavTabDetailCell" owner:self options:nil] objectAtIndex:0];
        cell.mImageView.image = [self.arrayImage objectAtIndex:indexPath.row] ;
    }
    return cell ;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    UIImage *img = [self.arrayImage  objectAtIndex:indexPath.row] ;
    return img.size.height + 10 ;
    
    
}
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    return nil ;
}


@end

#pragma Mark- -------------------FavTabDetailCell-----------------------

@implementation FavTabDetailCell

@synthesize mImageView ;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}


- (void)dealloc
{
    [mImageView release] ;
    [super dealloc];
}

@end

